<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<html>
<head>
    <title>文档列表</title>
    <link rel="stylesheet" href="${ctx}/static/styles/news/newslist.css" type="text/css">
</head>

<body>
<div class="news-main">
    <div class="container">
        <h2>文档列表</h2>
        <a href="${ctx}/doc/create" class="btn btn-primary">新增</a>
        <ul class="news-list">
            <c:forEach items="${docs.content}" var="doc">
                <li class="news-item std-item">
                    <div class="news-title">
                        <a href="${ctx}/doc/detail/${doc.id}">${doc.title}</a>
                    </div>

                    <div class="std-line">
                        摘要：${doc.summary}
                    </div>
                    <div class="std-line">
                        关键词：<span class="std-item-it">${doc.keywords}</span>
                    </div>
                    <div class="news-info">
                        <span>上传时间：<fmt:formatDate value="${doc.createDate}" type="date" dateStyle="long"/></span>
                    </div>
                    <div class="news-info">
                        <span>文档年份：<fmt:formatDate value="${doc.docTime}" type="date" dateStyle="long"/></span>
                    </div>
                    <div style="margin-bottom: 5px">
                        <a href="${ctx}/para/doc?docId=${doc.id}">查看文档相关段落</a>
                        <a style="margin-left: 70%" class="btn btn-warning" href="${ctx}/doc/detail/${doc.id}">查看</a>
                        <a class="btn btn-success" href="${ctx}/doc/update/${doc.id}">编辑</a>
                        <a class="btn btn-danger" href="${ctx}/doc/delete/${doc.id}">删除</a>
                        <a class="btn btn-danger" onclick="addWriteDoc('${doc.id}')">加入编研</a>
                    </div>
                </li>
            </c:forEach>
        </ul>
        <a class="btn btn-danger" href="${ctx}/doc/writeDoc">编研文档</a>
        <tags:pagination page="${docs}" paginationSize="10"/>
    </div>
</div>
<script>
    function addWriteDoc(data) {
        var docId = data
        $.ajax({
            type: "get",
            url: "${ctx}/doc/addUpdateDoc/" + data,
            success: function () {
                alert("加入成功！")
            }
        });
    }
</script>
</body>
</html>
